<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html>
<head>
<base href="${BaseContext }">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>添加更新客房</title>
<link href="${pageContext.request.contextPath}/css/bootstrap.min.css" rel="stylesheet">
<script src="${pageContext.request.contextPath}/js/bootstrap.min.js"></script>
<script src="${pageContext.request.contextPath}/js/jquery.js"></script>
</head>
<body>

<nav class="navbar-inverse">
	<div class="container">
		<!-- Brand and toggle get grouped for better mobile display -->
		<div class="navbar-header">
			<a class="navbar-brand" href="#">宾馆客房管理系统 : </a>
		</div>
		<div class="collapse navbar-collapse"
			 id="bs-example-navbar-collapse-9">
			<ul class="nav navbar-nav">
				<li class="active" ><a href="${pageContext.request.contextPath}/room/list.do">客房管理</a></li>
				<li ><a href="${pageContext.request.contextPath}/order/list.do">订单管理</a></li>
				<li ><a href="${pageContext.request.contextPath}/customer/list.do">客户管理</a></li>
				<li ><a href="${pageContext.request.contextPath}/user/list.do">员工管理</a></li>
				<li ><a href="${pageContext.request.contextPath}/behind/Mouth.jsp">月营业额统计</a></li>
				<li ><a href="${pageContext.request.contextPath}/behind/Year.jsp">年营业额统计</a></li>
			</ul>
			<p class="navbar-text navbar-right">
				<span>${username}</span> <i class="glyphicon glyphicon-log-in" aria-hidden="true"></i>&nbsp;&nbsp;
				<a href="${pageContext.request.contextPath}/exit.do" class="navbar-link">退出</a>
			</p>
		</div>
	</div>
</nav>

<div class="jumbotron" style="padding-top: 55px;padding-bottom: 15px;">
		<div class="container">
			<c:if test="${empty room.id}">
				<h2>添加客房</h2>
			</c:if>
			<c:if test="${not empty room.id}">
				<h2>更新客房</h2>
			</c:if>
		</div>
	</div>


	<div class="container" style="margin-top: 20px;">

		<form id="form" class="form-horizontal" action="${pageContext.request.contextPath}/room/addRoom.do?strId=${room.id}"
			method="post" enctype="multipart/form-data">
			<input value="${room.id}" name="id" type="hidden" >
			<div class="form-group">
				<label  class="col-sm-2 control-label">房间号</label>
				<div class="col-sm-10">
					<input type="text" class="form-control" name="roomnum"
						 placeholder="房间号" value="${room.roomnum}">
				</div>
			</div>

			<div class="form-group">
				<label  class="col-sm-2 control-label">楼层</label>
				<div class="col-sm-10">
					<input type="text" class="form-control" name="floor"
						   placeholder="楼层" value="${room.floor}">
				</div>
			</div>

			<div class="form-group">
				<label  class="col-sm-2 control-label">价格</label>
				<div class="col-sm-10">
					<input type="text" class="form-control" name="price"
						   placeholder="价格" value="${room.price}">
				</div>
			</div>

			<div class="form-group">
				<label  class="col-sm-2 control-label">状态</label>
				<div class="col-sm-10">
					<input type="text" class="form-control" name="status"
						 placeholder="状态" value="${room.status}">

				</div>
			</div>
			<div class="form-group">
				<label  class="col-sm-2 control-label">房间类型</label>
				<div class="col-sm-10">

					<select name="type" class="form-control">
						<option class="form-control" value="刺激心跳房" ${room.type == "刺激心跳房" ? 'selected':''}>刺激心跳房</option>
						<option class="form-control" value="浪漫双人房" ${room.type == "浪漫双人房" ? 'selected':''}>浪漫双人房</option>
						<option class="form-control" value="无敌快乐房" ${room.type == "无敌快乐房" ? 'selected':''}>无敌快乐房</option>
						<option class="form-control" value="豪华海景房" ${room.type == "豪华海景房" ? 'selected':''}>豪华海景房</option>
					</select>
				</div>
			</div>
			<div class="form-group">
				<label  class="col-sm-2 control-label">可住人数</label>
				<div class="col-sm-10">
					<input type="text" class="form-control" name="peoplenum"
						 placeholder="可住人数" value="${room.peoplenum}">
				</div>
			</div>
			<div class="form-group">
				<label  class="col-sm-2 control-label">图片</label>
				<div class="col-sm-10">
					<input id="file" multiple="multiple" type="file" class="form-control" name="file" >
					<img class="img-thumbnail" id="picture"  alt="" src="">
<%--					http://zhiyou01/${room.imageurl}--%>
					<input id="image" name="imageurl" value="" type="hidden">
				</div>
			</div>

			<div class="form-group">
				<label class="col-sm-2 control-label">客户入住时间</label>
				<div class="col-sm-10">
					<input type="date" class="form-control" name="startTime"
						placeholder="客户入住时间"  value="${room.startTime}"/>

				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">客户离开时间</label>
				<div class="col-sm-10">
					<input type="date" class="form-control" name="endTime"
						placeholder="客户离开时间"  value="${room.endTime}"/>
				</div>
			</div>

			<div class="form-group">
				<div class="col-sm-offset-2 col-sm-10">
					<button type="submit" class="btn  btn-primary">保存</button>
					<a href="/room/list.do" class="btn btn-default">返回列表</a>
				</div>
			</div>
		</form>
	</div>
<script type="text/javascript">
	$("#file").change(function() {
		var formData = new FormData($("#form")[0]);//获得表单信息
		$.ajax({
			url: "/room/ajaxFileUpdate.do",
			type: "post",
			data: formData,
			async: false,
			cache: false,
			contentType: false,
			processData: false,
			success: function (data) {
				console.log(data);
				//alert(data.code);
				//alert(data.msg);
				//alert(data.data);
				$("#picture").attr("src", data.data);
				$("#image").val(data.data);
				//alert($("#image").val());
			},
			error: function () {
				alert("服务器正忙,请稍后再试!")
			}
		});
	})
</script>


</body>
</html>